Skip to content

[fix][test] Fix IllegalArgumentException in bucket range validation for delayed message delivery#9

Closed
Denovo1998 wants to merge 2 commits into
masterfrom
delayed_message_optimize
Closed

[fix][test] Fix IllegalArgumentException in bucket range validation for delayed message delivery#9
Denovo1998 wants to merge 2 commits into
masterfrom
delayed_message_optimize

Conversation

@Denovo1998

@Denovo1998 Denovo1998 commented Aug 3, 2025

Copy link
Copy Markdown
Owner

Fixes #xyz

Main Issue: #xyz

PIP: #xyz

Motivation

Fixed race conditions in thread safety tests that were causing intermittent IllegalReferenceCountException failures due to improper resource cleanup order and unrealistic concurrent write patterns.

Modifications

  1. Enhanced Thread Safety Test Design
  • Fixed concurrent write race condition: Changed testConcurrentContainsMessageWithWrites from concurrent writes to sequential writes with concurrent reads, matching real-world
    usage patterns where addMessage is called sequentially
  • Improved test structure: Single writer thread generates sequential ledgerIds (1000, 1001, 1002...) while multiple reader threads concurrently call containsMessage()
  • Added proper error handling: Enhanced exception tracking and reporting with detailed logging
  1. Fixed Resource Cleanup Race Condition
  • Resolved IllegalReferenceCountException: Fixed tearDown method to shutdown ExecutorService before closing tracker, preventing threads from accessing released Netty ByteBufs
  • Improved cleanup order: Ensures all background threads are terminated before releasing resources

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: apache#24620

@coderzc

coderzc commented Aug 11, 2025

Copy link
Copy Markdown

Can you explain how the ledgerId decreases in the actual message dispatch process?

@Denovo1998

Copy link
Copy Markdown
Owner Author

Can you explain how the ledgerId decreases in the actual message dispatch process?

@coderzc Will not appear. This is actually a problem with the test itself, the addMessage write operation should be executed sequentially. We just need to modify testConcurrentContainsMessageWithWrites.

@codecov

codecov Bot commented Aug 12, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@fa28d1c). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #9   +/-   ##
=========================================
  Coverage          ?   74.33%           
  Complexity        ?    33058           
=========================================
  Files             ?     1880           
  Lines             ?   146433           
  Branches          ?    16789           
=========================================
  Hits              ?   108851           
  Misses            ?    28934           
  Partials          ?     8648           
Flag Coverage Δ
inttests 26.72% <ø> (?)
systests 23.38% <ø> (?)
unittests 73.81% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Denovo1998 Denovo1998 changed the title [fix][broker] Fix IllegalArgumentException in bucket range validation for delayed message delivery [fix][test] Fix IllegalArgumentException in bucket range validation for delayed message delivery Aug 12, 2025
@Denovo1998 Denovo1998 closed this Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants